// DCELVertex.cpp: implementation of the DCELVertex class.
//
//////////////////////////////////////////////////////////////////////

#include "DCELVertex.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//edit by lqw
DCELVertex::DCELVertex(DCELVertexType dt)
: m_enVertexType(dt)
{

}

DCELVertex::DCELVertex()
{

}

DCELVertex::DCELVertex(double time)
: leaving(0), auxData(0), originIndex(0), globalIndex(-1),
isFixed(false), appearTime(time)
{
}

//edited by lqw
DCELVertex::DCELVertex(double x, double y)
: leaving(0), auxData(0), coords(x, y), originIndex(0), globalIndex(-1),isFixed(true)
{

}

DCELVertex::DCELVertex(double x, double y, double time)
: leaving(0), auxData(0), coords(x, y), originIndex(0), globalIndex(-1),
isFixed(true), appearTime(time)
{
}

DCELVertex::DCELVertex(int i, double x, double y, double time)
: leaving(0), auxData(0), coords(x, y), originIndex(i), globalIndex(-1),
isFixed(true), appearTime(time)
{
}

DCELVertex::~DCELVertex()
{

}

DCELHalfEdge* DCELVertex::getEdgeTo(const DCELVertex* v) const
{
	DCELHalfEdge* rval = 0;

	if (leaving) {
		if (leaving->twin->origin == v) {
			rval = leaving;
		} else {
			DCELHalfEdge* test = leaving->twin->next;
			while (rval == 0 && test != leaving) {
				if (test->twin->origin == v) {
					rval = test;
				} else {
					test = test->twin->next;
				}
			}
		}
	}

	return rval;
}
